//
//  Approvable.swift
//  ZYA
//
//  Created by 邱仙凯 on 2020/3/9.
//  Copyright © 2020 zwb. All rights reserved.
//

import UIKit
 

func tranTodoType(type:Int?) -> TodoType {
    if type == 1 {
        return .normal
    }
    if type == 2 {
        return .transform
    }
    if type == 3 {
        return .remind
    }
    return .normal
}

 
class AuditTextBg:UIView {
    var blockx:UIView = {
        var v = UIView()
        v.backgroundColor = UIColor(kshex: "#4972F9")
        return v
    }()
    lazy var audittextTip: UILabel = {
        
        let label = UILabel()
        label.text = "审核意见:"
        label.font = UIFont.systemFont(ofSize: 15)
        label.textColor = .darkGray
        label.numberOfLines = 2
        return label
    }()
    lazy var audittext: UITextView = {
        let v = UITextView()
        v.inputAccessoryView = KSToolbar(view: self)
//        v.placeholder = "输入审批意见"
        v.textAlignment = .left
        v.layer.borderWidth = 1
        v.layer.borderColor = UIColor(kshex: "#CACEE1").cgColor
        v.layer.cornerRadius = 6
        v.font = UIFont.systemFont(ofSize: 15)
        return v
    }()
    override init(frame: CGRect) {
        super.init(frame: frame)
        addSubview(blockx)
        addSubview(audittextTip)
        addSubview(audittext)
        blockx.snp.makeConstraints { make in
            make.left.equalToSuperview().offset(8)
            make.width.equalTo(4)
            make.height.equalTo(14)
            make.centerY.equalTo(audittextTip)
        }
        audittextTip.snp.makeConstraints { (make) in
            make.left.equalTo(blockx.snp.right).offset(5)
            make.width.equalTo(72)
            make.top.equalTo(self).offset(5)
        }
        audittext.snp.makeConstraints { (make) in
            make.top.equalTo(audittextTip.snp.bottom).offset(5)
            make.left.equalTo(blockx)
            make.right.equalTo(self).offset(-8)
            make.bottom.equalTo(self).offset(-5)
        }
       
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}
class AuditBtnBg:UIView {
    
    lazy var audittextTip: UILabel = {
        
        let label = UILabel()
        label.text = "组:"
        label.font = UIFont.systemFont(ofSize: 15)
        label.textColor = .darkGray
        label.numberOfLines = 0
        return label
    }()
    lazy var btn: UIButton = {
        let v = UIButton()
        v.setTitleColor(.black, for: .normal)
        v.backgroundColor = UIColor(kshex: "f9f9f9")
        v.setTitle("", for: .normal)
        v.titleLabel?.font = UIFont.systemFont(ofSize: 15)
        v.titleLabel?.numberOfLines = 0
        return v
    }()
    override init(frame: CGRect) {
        super.init(frame: frame)
        addSubview(audittextTip)
        addSubview(btn)
        btn.snp.makeConstraints { (make) in
          
            make.left.equalTo(audittextTip.snp.right).offset(10)
            make.right.equalTo(self).offset(-15)
       
            make.top.equalToSuperview().offset(5)
            make.bottom.equalTo(self).offset(-5)
        }
        audittextTip.snp.makeConstraints { (make) in
            make.left.equalTo(self).offset(5)
            make.width.equalTo(72)
            make.centerY.equalTo(self)
        }
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}


class AuditFileButton:UIButton {
    override init(frame: CGRect) {
        super.init(frame: frame)
        
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    override func layoutSubviews() {
        super.layoutSubviews()
        
        // 设置title
        titleLabel?.frame = CGRect(x: 0 , y: 0, width: self.frame.width, height: self.frame.height)
        
        
    }
}





class AuditPInfoButton:UIButton {
    override init(frame: CGRect) {
        super.init(frame: frame)
        
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    override func layoutSubviews() {
        super.layoutSubviews()
        let imgW:CGFloat = 20
        // 设置title
        titleLabel?.frame = CGRect(x: 0 , y: 0, width: self.frame.width - imgW - 3, height: self.frame.height)
        // 设置imageView
        imageView?.frame = CGRect(x: self.frame.width - imgW - 3 , y: (self.frame.height - imgW) * 0.5, width: imgW, height: imgW)
        
    }
}
